﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DigitalRubyShared;
public class LevelFGScaleIncrease : MonoBehaviour
{
    public GameObject targetObject;
    private ScaleGestureRecognizer scaleGesture;
    public GameLevelItem gameLevelItem;
    private bool isScale1 = false;
    private void OnEnable()
    {
        scaleGesture = new ScaleGestureRecognizer();
        scaleGesture.StateUpdated += RotateGestureCallback;
        FingersScript.Instance.AddGesture(scaleGesture);
    }

    private void OnDisable()
    {
        if (FingersScript.HasInstance)
        {
            FingersScript.Instance.RemoveGesture(scaleGesture);
        }
    }

    private void RotateGestureCallback(DigitalRubyShared.GestureRecognizer gesture)
    {
        if (isScale1)
            return;
        Debug.Log(gesture.State.ToString());
        if (gesture.State == GestureRecognizerState.Executing)
        {
            if (scaleGesture.ScaleMultiplier > 1)
                targetObject.transform.localScale *= scaleGesture.ScaleMultiplier;
        }

        if (targetObject.transform.localScale.x >= 2 )
        {
            isScale1 = true;
            gameLevelItem.TriggerResult(true);
        }
    }



}
